public class Node {

	private State state;
	private Node parent;
	private char action;
	private int depth;
	private int pathCost;
	private int heuristic;

	public Node(State state, Node parent, char action, int pathCost) {
		super();
		this.state = state;
		this.parent = parent;
		this.action = action;
		if (this.parent == null)
			this.depth = 0;
		else
			this.depth = parent.depth + 1;
		this.pathCost = pathCost;
	}

	public Node(State state, Node parent, char action) {
		super();
		this.state = state;
		this.parent = parent;
		this.action = action;
		if (this.parent == null)
			this.depth = 0;
		else
			this.depth = parent.depth + 1;
	}

	public State getState() {
		return state;
	}

	public void setState(State state) {
		this.state = state;
	}

	public Node getParent() {
		return parent;
	}

	public void setParent(Node parent) {
		this.parent = parent;
	}

	public char getAction() {
		return action;
	}

	public void setAction(char action) {
		this.action = action;
	}

	public int getDepth() {
		return depth;
	}

	public void setDepth(int depth) {
		this.depth = depth;
	}

	public int getPathCost() {
		return pathCost;
	}

	public void setPathCost(int pathCost) {
		this.pathCost = pathCost;
	}

	public void setPathCost() {
		int parentCost = this.parent.pathCost;
		this.pathCost = parentCost + 1;
	}

	public int getHeuristic() {
		return heuristic;
	}

	public void setHeuristic(int heuristic) {
		this.heuristic = heuristic;
	}

	public boolean isEqual(Node node) {
		if (state.isEqual(node.state))
			return true;
		else
			return false;
	}

	public String toString() {
		String s;
		s = "(" + state.getX() + "," + state.getY() + ") facing ";
		if (state.getOrientation() == 0)
			s += "north, action: ";
		if (state.getOrientation() == 1)
			s += "east, action: ";
		if (state.getOrientation() == 2)
			s += "south, action: ";
		if (state.getOrientation() == 3)
			s += "west, action: ";
		s += action + ", depth: " + depth;
		return s;
	}

}
